package com.dnjn.happiness.emo.webapi.c3v8;

import com.dnjn.happiness.common.config.ext.SpringContextHolder;
import com.dnjn.happiness.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class C3v8Config {

    public final static String SECRET_KEY = "84DA537BF029AAD92C7AC524A685E2A1";
    public final static String HOST = "http://172.16.202.56:85";

    public static String getHost() {
        String host = getEnv("c3v8.host");
        if (StringUtils.isBlank(host)) {
            host = HOST;
        }
        return host;
    }


    public static String getSecretKey() {
        String secretKey = getEnv("c3v8.secretKey");
        if (StringUtils.isBlank(secretKey)) {
            secretKey = SECRET_KEY;
        }
        return secretKey;
    }

    private static String getEnv(String key) {
        try {
            return SpringContextHolder.getContext().getEnvironment().getProperty(key);
        } catch (Exception e) {
            log.warn(String.format("[warn] %s %s; config [%s] first!", e.getMessage(), e.getClass().getCanonicalName(), key));
        }
        return null;

    }

}
